package com.hoyue.exam.controller;

import com.hoyue.classroom.bean.Classes;
import com.hoyue.classroom.bean.Course;
import com.hoyue.classroom.service.ClassesService;
import com.hoyue.classroom.service.CourseService;
import com.hoyue.common.utils.CoreConst;
import com.hoyue.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author SiMan
 * @date 2019/8/29 11:07
 */

@Controller
@RequestMapping("")
public class AdminRenderController {

	@Autowired
	private CourseService courseService;

	@Autowired
	private ClassesService classesService;

	@Autowired
	private UserService userService;


	@GetMapping("/questions")
	public String questions(Model model) {
		Course course = new Course();
		course.setStatus(CoreConst.STATUS_INVALID);
		List<Course> courses = courseService.selectCourses(course);
		model.addAttribute("courses",courses);

		return "question/list";
	}

	/*考试*/
	@GetMapping("/exams")
	public String exams(Model model) {
		try {
			Course course = new Course();
			course.setStatus(CoreConst.STATUS_INVALID);
			List<Course> courses = courseService.selectCourses(course);
//		List<Institute> institutes = instituteService.selectAll();
			List<Classes> classes = classesService.selectAll();
			List<String> grades = userService.selectGradeList();
			model.addAttribute("courses", courses);
//		model.addAttribute("institutes", institutes);
			model.addAttribute("classes", classes);
			model.addAttribute("grades", grades);
			return "exam/list";
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "index";
	}
}
